const CURD = require('../factory/controller')
const { nowDate } = require('../hooks/format')

class Todo extends CURD {
    async insertOne(req, res) {
        const { todo, todoId } = req.body
        try {
            todo && await this.command.add({ todoId, todo, isDone: false, created: nowDate() })
            res.json({ code: 200, msg: '成功添加任务列表', todo: todo ? todo : '缺少这个传参' })
        } catch (err) {
            res.json({ code: 500, msg: '失败', err })
        }
    }
}

module.exports = Todo
